ec.pkg("ec.account");
ec.load("jquery.autocomplete", {
  loadType: "lazy",
  callback: function () {
    $("#search-kw").autocomplete({
      serviceUrl: "/search_keywords",
      minChars: 1,
      maxHeight: 400,
      deferRequestBy: 100
    })
  }
});
ec.load("ec.box");
ec.account.customerInfo = function () {
  this.zmPoint = null;
  this.empiricalValue = null
};
var g_pointBlance = 0;
var g_couponCount = 0;
var g_balanceAmount = 0;
var g_newMsgCount = 0;
var g_totalPoint = 0;
var minCartNum = 0;
window.gid = function (b) {
  return document.getElementById(b)
};
ec.account.isLogin = function () {
  return ec.account.id && ec.account.loginName
};
ec.account.syncCustomSession = function (b) {
  new ec.ajax().get({
    async: false,
    url: "/account/syncEmailAndMobile.json",
    dataType: "json",
    timeout: 10000,
    successFunction: function (c) {
      if (b && b != undefined) {
        b(c)
      }
      return
    },
    timeoutFunction: function () {
      return
    },
    errorFunction: function () {
      return
    }
  })
};
ec.account.getStatus = function (b) {
  $.ajax({
    url: domainAccount + "/status.json?t=" + new Date().getTime(),
    dataType: "json",
    timeout: 10000,
    jsonop: "callback",
    type: "get",
    success: function (d) {
      if (d && d.id > 0) {
        ec.account.id = d.id;
        ec.account.uid = d.uid;
        ec.account.name = d.name;
        ec.account.nickName = d.nickName;
        ec.account.displayName = d.displayName;
        ec.account.loginName = d.loginName;
        ec.account.email = d.email;
        ec.account.mobile = d.mobile;
        ec.account.isQueue = d.isQueue;
        ec.account.custGrade = d.custGrade;
        ec.account.custPrivilege = d.custPrivilege;
        ec.account.custPoint = d.custPoint;
        ec.account.userState = d.userState;
        ec.account.isAuthCust = d.isAuthCust;
        var c = ec.util.cookie.get("ifl_v");
        if (c == "1") {
          $.ajax({
            url: "/account/load",
            type: "POST"
          })
        }
      }
      b()
    }
  })
};
ec.account.getAccountStatus = function (b, d, c) {
  if (b) {
    if (c) {
      ec.load({
        url: domainMain + "/account/status?" + (new Date()).getTime(),
        type: "js",
        onload: d
      })
    } else {
      ec.load({
        url: domainMain + "/account/status?" + (new Date()).getTime(),
        type: "js",
        loadType: "lazy",
        onload: d
      })
    }
  }
};
ec.account.getLoginInfo = function (h, f) {
  var b = ec.util.cookie.get("ac_li");
  var d = ec.util.cookie.get("uid");
  var c = ec.util.cookie.get("isValCas");
  try {
    if (d && c && "false" == c) {
      ec.account.id = ec.util.cookie.get("uid");
      ec.account.uid = ec.util.cookie.get("uid");
      ec.account.name = ec.util.cookie.get("user");
      ec.account.nickName = ec.util.cookie.get("name");
      ec.account.displayName = ec.util.cookie.get("displayName");
      ec.account.loginName = ec.util.cookie.get("user");
      ec.account.isValCas = "false";
      $.ajax({
        url: "/account/load?uid=" + d,
        async: false,
        type: "POST"
      });
      ec.account.getAccountStatus(d, h, f);
      ec.account.isValCas = ec.util.cookie.get("isValCas");
      h();
      return
    }
    if (b && d) {
      ec.account.id = ec.util.cookie.get("uid");
      ec.account.uid = ec.util.cookie.get("uid");
      ec.account.name = ec.util.cookie.get("user");
      ec.account.nickName = ec.util.cookie.get("name");
      ec.account.displayName = ec.util.cookie.get("displayName");
      ec.account.loginName = ec.util.cookie.get("ac_loNa");
      ec.account.email = ec.util.cookie.get("ac_lel");
      ec.account.mobile = ec.util.cookie.get("ac_lmi");
      ec.account.isQueue = ec.util.cookie.get("ac_liq");
      ec.account.custGrade = ec.util.cookie.get("ac_lgc");
      ec.account.custPrivilege = ec.util.cookie.get("ac_cp");
      ec.account.custPoint = ec.util.cookie.get("ac_ltp");
      ec.account.userState = ec.util.cookie.get("ac_lus");
      h();
      return
    }
  } catch (g) {}
  ec.account.getAccountStatus(d, h, f)
};
ec.account.confirmSaleConfig = function () {
  var b = $("#checkSaleConfig").attr("checked") ? "1" : "0";
  new ec.ajax().get({
    url: "/saleinfo/setSaleInfoRcvCfg.json?send_sms=" + b + "&send_email=" + b + "&t=" + new Date().getTime(),
    async: true,
    timeout: 10000,
    successFunction: function (c) {
      if (!c.success) {
        return
      }
      ec.util.cookie.set("isFirstLogin", "0", {
        domain: ".vmall.com",
        path: "/"
      });
      window.location.href = c.href
    },
    timeoutFunction: function () {
      return
    },
    errorFunction: function () {
      return
    }
  })
};
ec.account.displaySaleConfig = function () {
  var d = ec.util.cookie.get("isFirstLogin");
  if (d && d == "1") {
    var b = [];
    b.push('      <div class="box-prompt-success-area">');
    b.push('         <div class="h pdt-40 pdb-40">');
    b.push('             <img src="' + imagePath + '/echannel/sprites/sprites33.png" alt="">');
    b.push("         </div>");
    b.push('        <div class="b pdb-16">');
    b.push('            <label class="vat"><input id="checkSaleConfig" class="vam" type="checkbox" checked />&nbsp;&nbsp;<p class="f12 gray inline-block vam">同意接收营销信息</p></label>&nbsp;&nbsp;<a href="/help/faq-2635.html" target="_blank" class="vam f12 blue">更多相关信息</a>');
    b.push("        </div>");
    b.push("     </div>");
    b.push('    <div class="box-custom-button">');
    b.push('       <a onclick="ec.account.confirmSaleConfig()"  class="box-ok box-button-style-2"><span>领取新人礼包</span></a>');
    b.push("    </div>");
    var c = new ec.box(b.join(" "), {
      boxid: "ec_sale_config",
      boxclass: "ol_box_4",
      title: '<font color="#CA151E">欢迎来到华为商城</font>',
      remember: false,
      width: 540,
      showButton: false
    });
    c.open()
  }
};
ec.account.getZMInfo = function () {
  $.ajax({
    url: domainUc + "/zm/queryZM.json",
    dataType: "jsonp",
    timeout: 10000,
    timeoutFunction: function () {
      alert("操作超时，请重试！")
    },
    success: function (b) {
      if (b.resultCode == "200" && b.userZMInfoVO) {
        if (b.userZMInfoVO.certifyStatus == 1) {
          $("#zhimaPoint").html(b.userZMInfoVO.creditScore);
          ec.account.customerInfo.zmPoint = b.userZMInfoVO.creditScore
        }
      }
    }
  })
};
ec.account.getAccountInfo = function (d) {
  var c = ec.util.cookie.get("isEnterpriseUser");
  if ("true" == c) {
    $("#preferential").html('<a href="' + domainMain + '/member/enterprise" rel="nofollow">优惠内购</a>').show();
    $("#li-enterprise-preferential").html('<a href="' + domainMain + '/member/enterprise"><span>优惠内购</span></a>').show();
    $("#li-enterprise").html('<a href="' + domainMain + '/member/enterprise"><span>优惠内购</span></a>').show()
  }
  var b = ec.util.cookie.get("companyUser");
  if ("true" == b) {
    $("#li-companyUserInfo").html('<a href="/member/company/info" ><span>企业购用户信息</span></a>');
    $("#li-companyOrder").html('<a href="/member/company/intend" ><span>采购意向单</span></a>');
    $("#li-companyOrderList").html('<a href="/member/company/order" ><span>企业购订单</span></a>');
    $("#li-companyQues").html('<a href="/member/company/question" ><span>常见问题</span></a>');
    $("#li-company").show()
  }
  $.ajax({
    url: domainMain + "/member/accountInfo.json",
    dataType: "json",
    timeout: 10000,
    timeoutFunction: function () {
      alert("操作超时，请重试！")
    },
    success: function (e) {
      if (e && e.enterpriseUser) {
        $("#preferential").html('<a href="' + domainMain + '/member/enterprise" rel="nofollow">优惠内购</a>').show();
        $("#li-enterprise-preferential").html('<a href="' + domainMain + '/member/enterprise"><span>优惠内购</span></a>').show();
        $("#li-enterprise").html('<a href="' + domainMain + '/member/enterprise"><span>优惠内购</span></a>').show()
      }
      if (!e.success && e.code == "login") {
        ec.account.id = ec.util.cookie.set("uid", null);
        ec.account.loginName = ec.util.cookie.set("user", null);
        $("#unlogin_status").show();
        $("#top_login").removeClass().addClass("header-toolbar hide");
        $("#top_unlogin").removeClass().addClass("header-toolbar");
        $("#gg_login").removeClass().addClass("i-mall-prompt clearfix hide");
        $("#gg_unlogin").removeClass().addClass("i-mall-prompt clearfix");
        $("#privilege_is_login").removeClass().addClass("privilege-user privilege-user-gray");
        $(".privilege-user-login").show();
        $("#personal_privilege").hide();
        $(".user-canvas").removeClass().addClass("user-canvas hide");
        $(".user-canvas").removeAttr("style");
        $("#privilege-user-img").find("img").attr("src", "images/echannel/misc/img_not_logged_in.png");
        $("#balanceicon_privilege").html("--");
        $("#couponicon_privilege").html("--");
        $("#balanceAmount_privilege").html("--");
        $("#header-cart-total").html(0);
        $(".business-user-info").hide();
        $(".business-user-bottom").find(".business-user-num").hide();
        $(".business-user").addClass("business-user-gray");
        $("#userImgID").find("img").attr("src", "/images/echannel/misc/img88_black.jpg");
        $("#loginUserInfoId").show();
        $(".business-user-bottom").find(".business-user-explain").show();
        return
      }
      d(e)
    }
  })
};
ec.account.showCustoemrInfo = function (k) {
  if (parseInt(k.couponCount) >= 0) {
    g_couponCount = k.couponCount;
    $("#top-couponCount").html(k.couponCount)
  }
  if (k.newMsgCount) {
    g_newMsgCount = k.newMsgCount;
    $("#top-newMsgCount").html(k.newMsgCount).attr("class", (k.newMsgCount <= 0) ? "hide" : "");
    if (k.newMsgCount > 0) {
      $("#li-msg em").text("(" + k.newMsgCount + ")")
    }
  }
  if (k.customerInfo) {
    var e = k.customerInfo;
    if (e.headPictureURL) {
      $("#customerPic").attr("src", e.headPictureURL);
      $("#gg_customerPic").attr("src", e.headPictureURL)
    } else {
      var f = $("#customerPic").attr("imgpath");
      $("#customerPic").attr("src", f + "/echannel/misc/img_logged_in.png");
      $("#gg_customerPic").attr("src", f + "/echannel/misc/img_logged_in.png")
    }
    if (e.totalPoint) {
      $("#empiricalValue").html(e.totalPoint);
      ec.account.customerInfo.empiricalValue = e.totalPoint;
      g_totalPoint = e.totalPoint
    }
    if (e.mobileStatus && (e.mobileStatus == "1")) {
      $("#validateMobile").html("已验证手机").removeClass("link-non-validated").addClass("link-validated")
    }
    if (e.emailStatus && (e.emailStatus == "1")) {
      $("#validateMail").html("已验证邮箱").removeClass("link-non-validated").addClass("link-validated")
    }
    if (e.isAuthentication && (e.isAuthentication == "1")) {
      $("#certification").html("已实名认证").removeClass("link-non-validated").addClass("link-validated")
    }
  }
  if (k.gradeConfig) {
    var j = k.gradeConfig.maxScores;
    var g = k.gradeConfig.minScores;
    var d = j - g;
    var l = g_totalPoint;
    var c = l - g;
    if (isNaN(d)) {
      d = 50000
    }
    if (c > 50000) {
      c = 50000
    }
    var h = (c / d) * 100;
    if (isNaN(h)) {
      h = 0;
      l = 0
    }
    if (h <= 0) {
      h = 0
    } else {
      h = Math.round(h)
    }
    var b = k.gradeConfig.code;
    $("#gg_jyz").attr("style", "width: " + h + "%");
    var i = k.gradeConfig.nextGradeName;
    if (i == "maxlevel") {
      j = 100000
    }(function () {
      ec.account.privilege_updateProgress(j, g, l, b)
    })()
  }
};

function htmlEncode(c) {
  var b = {
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&#39;",
    "/": "&#x2F;"
  };
  return String(c).replace(/[&<>"'/]/g, function (d) {
    return b[d]
  })
}
ec.account.getBalanceAmount = function () {
  $.ajax({
    url: domainCds + "/gateway/queryBalance",
    dataType: "jsonp",
    success: function (b) {
      if (b.resultCode == 0) {
        if (b.balanceAmount != null) {
          g_balanceAmount = (parseFloat(b.balanceAmount)).toFixed(2)
        } else {
          g_balanceAmount = 0
        }
        $("#balanceAmount").html(g_balanceAmount);
        if (parseInt(g_balanceAmount) > parseInt(999)) {
          $("#balanceAmount_privilege").empty().html('<a href="/member/balance?t=' + new Date().getTime() + '" target="_blank">' + 999 + "+</a>")
        } else {
          $("#balanceAmount_privilege").empty().html('<a href="/member/balance?t=' + new Date().getTime() + '" target="_blank">' + g_balanceAmount + "</a>")
        }
        $("#balanceAmount_myCenter").html(g_balanceAmount);
        $("#balanceAmount_myCenter").removeClass("p-price-no")
      }
    }
  })
};
ec.ready(function () {
  var f = function () {
    if (ec.account.isLogin()) {
      var k = ec.util.escapeHtml(ec.account.displayName) || ec.util.escapeHtml(ec.account.nickName) || ec.util.escapeHtml(ec.account.name) || ec.account.loginName;
      $("#customer_name").html(k);
      if ($("#cart_unlogin_info")[0]) {
        $("#cart_unlogin_info p").html('<a href="/member?t=' + new Date().getTime() + '">' + k + "</a>")
      }
      $("#login_status,#cart_login_info").show();
      $("#up_user_center").show();
      $("#unlogin_status,#cust_login_info").hide();
      $("#loginName").html('<a href="/member?t=' + new Date().getTime() + '">' + k + "</a>");
      $("#up_loginName").html(k);
      $("#up_loginName_info").html(k);
      ec.account.showVipInfo();
      $("#top_login").removeClass().addClass("header-toolbar");
      $("#top_loginName").html(k);
      $("#top_unlogin").removeClass().addClass("header-toolbar hide");
      $("#gg_loginName").html("Hi," + k);
      $("#gg_login").removeClass().addClass("i-mall-prompt clearfix");
      $("#gg_unlogin").removeClass().addClass("i-mall-prompt clearfix hide");
      var i = ec.util.cookie.get("isAuthCust");
      if ("true" == i) {
        $("#authentication_y").show()
      } else {
        $("#authentication_n").show()
      }
      var j = ec.util.cookie.get("caibeiShowMsg"),
        g = ec.util.cookie.get("caibeiHeadShow"),
        h = ec.util.cookie.get("caibeiJifenUrl");
      if (j != undefined && j != null && j.length > 0) {
        $("#HeadShow").html(g);
        if (h != undefined && h != null && h.length > 0) {
          j = j + "<b>|</b><a href='" + h + "' title='我的彩贝积分' target='_blank'>我的彩贝积分</a>"
        }
        $("#ShowMsg").html(j);
        $("#caibeiMsg").show()
      }
      $("#newPointlogin_status").show();
      getPointBalance();
      if (window.location.pathname && (window.location.pathname == "/" || window.location.pathname == "/index.html")) {
        if (ec.account.isLogin()) {
          var l = ec.util.cookie.get("isFirstLogin");
          if (l && l == "1") {
            ec.account.displaySaleConfig()
          }
        }
      }
    } else {
      $("#gg_login").removeClass().addClass("i-mall-prompt clearfix hide");
      $("#gg_unlogin").removeClass().addClass("i-mall-prompt clearfix");
      $("#top_login").removeClass().addClass("header-toolbar hide");
      $("#top_unlogin").removeClass().addClass("header-toolbar")
    }
  };
  var b = function (l) {
    var k = "callback" + new Date().getTime(),
      h = "/account/login?type=frame&url=" + encodeURIComponent(domainMain + "/account/upCallback.html?funName=" + k + "&prePage=" + encodeURIComponent(encodeURIComponent(window.location.href))),
      g = "up-iframe-" + (new Date()).getTime(),
      i = '<iframe class="boxIframe" width="100%" height="100%" frameborder="0" name="' + g + '" src="about:blank" scrolling="no"></iframe><script>setTimeout(function(){window["' + g + '"].location.href="' + h + '";} ,100);</script>';
    var j = new ec.box(i, {
      boxid: "ec_login",
      title: " ",
      remember: false,
      width: 500,
      height: 600,
      showButton: false,
      onclose: function (m) {
        try {
          delete window[k]
        } catch (n) {
          window[k] = null
        }
        m.find("iframe").each(function () {
          this.contentWindow.close();
          jQuery(this).remove()
        })
      }
    }).open();
    window[k] = function () {
      if (typeof isUseAccount != "undefined" && isUseAccount == "true") {
        ec.account.getStatus(f)
      } else {
        ec.account.getLoginInfo(f, false);
        ec.util.cookie.get("ifl_v")
      }
      l();
      j.close()
    }
  };
  ec.account.afterLogin = function (g) {
    if (ec.account.isLogin()) {
      g()
    } else {
      b(g)
    }
  };
  if (typeof isUseAccount != "undefined" && isUseAccount == "true") {
    ec.account.getStatus(f)
  } else {
    ec.account.getLoginInfo(f, true)
  }
  var e = ec.util.cookie.get("cartId");
  var c = ec.util.cookie.get("cartAdded");
  if (c && c != e) {
    ec.util.cookie.set("cartAdded", null)
  }
  $("#login_status").hover(function () {
    ec.account.getAccountInfo(ec.account.showCustoemrInfo)
  }, function () {});
  var d = $("#vmall_index").val();
  if (typeof (d) != "undefined") {
    if (d == "vmall_index") {
      if (ec.account.isLogin()) {
        ec.account.getAccountInfo(ec.account.showCustoemrInfo);
        ec.account.getBalanceAmount()
      }
    }
  }
});
ec.account.showVipInfo = function () {
  if (ec.account.userState && ec.account.userState == "1") {
    $("#vip-inActive").hide();
    $("#vip-Active i").removeClass().addClass("icon-vip-level-" + ec.account.custGrade);
    $("#vip-Active").attr("title", "VMALL V" + ec.account.custGrade + "会员");
    $("#vip-Active").show();
    var b = [];
    b.push('<em class="vip-state" id="vip-info">&nbsp;&nbsp;&nbsp;&nbsp;');
    b.push('<a href="/member/point" title="VMALL V' + ec.account.custGrade + '会员" id="vip-Active" ><i class="icon-vip-level-' + ec.account.custGrade + '"></i></a>');
    b.push("</em>");
    $("#cart_unlogin_info p").append(b.join(""));
    $("#vip-Active-top i").removeClass().addClass("icon-vip-level-" + ec.account.custGrade);
    $("#vip-Active-top").attr("title", "VMALL V" + ec.account.custGrade + "会员");
    $("#vip-Active-gg").removeClass().addClass("icon-vip-level-" + ec.account.custGrade);
    if (ec.account.custGrade == "0") {
      $("#oldPeople").hide();
      $("#newPeople").show()
    } else {
      $("#oldPeople").show();
      $("#newPeople").hide()
    }
  } else {
    if (ec.account.isValCas && "false" == ec.account.isValCas) {
      $("#vip-inActive").hide();
      $("#vip-Active").hide();
      $("#vip-Active-top").removeClass().addClass("icon-vip-level-0");
      $("#vip-Active-gg").removeClass().addClass("icon-vip-level-0");
      $("#oldPeople").hide();
      $("#newPeople").show()
    } else {
      $("#cart_unlogin_info p").append('&nbsp;&nbsp;<em class="vip-state"><a class="link-noAct" href="/member/account" id="vip-inActive" title="请完善个人信息，即刻享受会员特权">去激活</a></em>');
      $("#vip-inActive").show();
      $("#vip-Active").hide();
      $("#vip-Active-top").removeClass().addClass("icon-vip-level-0");
      $("#vip-Active-gg").removeClass().addClass("icon-vip-level-0");
      $("#oldPeople").hide();
      $("#newPeople").show()
    }
  }
};
ec.pkg("ec.minicart");
ec.minicart.processCheck = function (c) {
  var b = c.itemList;
  for (var d = 0; d < b.length; d++) {
    var e = b[d];
    if (e.isBundle == "1") {
      if (e.bundleProp.selected == "1") {
        b[d].checked = true
      } else {
        b[d].checked = false
      }
    } else {
      if (e.productProp.selected == "1") {
        b[d].checked = true
      } else {
        b[d].checked = false
      }
    }
  }
};
ec.minicart.readyContent = function () {
  ec.cart.getMicroCartBaseInfo();
  ec.cart.getMicroCartTotalNumber(function (b) {
    if (b.cartNumber > 99) {
      $("#header-cart-total").html("99+")
    } else {
      $("#header-cart-total").html(b.cartNumber || 0)
    }
    minCartNum = parseInt($("#header-cart-total").html())
  })
};
ec.minicart.content = function () {
  ec.cart.getMicroCartFromOrder(function (f) {
    var c = f.cartInfo.cartVO,
      e = $("#minicart-pro-empty"),
      h = $("#minicart-pro-list-block"),
      g = $("#minicart-pro-settleup");
    var b = c;
    if (ec.minicart.microCartTpl) {
      var d = 0;
      if (b.miniTotalNumber == 0) {
        $("#button-minicart-go2confirm").hide();
        $("#disbutton-minicart-go2confirm").show()
      } else {
        $("#button-minicart-go2confirm").show();
        $("#disbutton-minicart-go2confirm").hide()
      }
      if (b.totalNumber > 0) {
        if (b.totalNumber > 99) {
          $("#header-cart-total").html("99+")
        } else {
          $("#header-cart-total").html(b.totalNumber || 0)
        }
        $("#micro-cart-totalPrice").html("&yen;&nbsp;" + b.miniTotalPrice.toFixed(2));
        if (b.miniTotalOriginalPrice != b.miniTotalPrice) {
          $("#micro-cart-totalOriginPrice").html("&yen;&nbsp;" + b.miniTotalOriginalPrice.toFixed(2))
        } else {
          $("#micro-cart-totalOriginPrice").html("")
        }
        ec.minicart.processCheck(b);
        $("#minicart-goods-list").html(ec.minicart.microCartTpl.parse("microCartList", b));
        h.show();
        g.show();
        e.hide();
        if (b.itemList.length > 5) {
          h.addClass("minicart-pro-list-scroll")
        } else {
          h.removeClass("minicart-pro-list-scroll")
        }
      } else {
        e.show();
        h.hide();
        g.hide()
      }
    }
  })
};
ec.minicart.click = function (b) {
  ec.minicart.click.send(b, function (d) {
    var c = d.cartInfo.cartVO;
    if (c.totalNumber > 99) {
      $("#header-cart-total").html("99+")
    } else {
      $("#header-cart-total").html(c.totalNumber || 0)
    }
    if (c.miniTotalNumber > 0) {
      $("#button-minicart-go2confirm").show();
      $("#disbutton-minicart-go2confirm").hide();
      $("#micro-cart-totalPrice").html("&yen;&nbsp;" + c.miniTotalPrice.toFixed(2));
      if (c.miniTotalOriginalPrice != c.miniTotalPrice) {
        $("#micro-cart-totalOriginPrice").html("&yen;&nbsp;" + c.miniTotalOriginalPrice.toFixed(2))
      } else {
        $("#micro-cart-totalOriginPrice").html("")
      }
    } else {
      $("#button-minicart-go2confirm").hide();
      $("#disbutton-minicart-go2confirm").show();
      $("#micro-cart-totalPrice").html("&yen;&nbsp;0.00");
      $("#micro-cart-totalOriginPrice").html("")
    }
  })
};
ec.minicart.convertToCart = function (j) {
  var m = [],
    h = [],
    k = [],
    n = [],
    l = [],
    b = [];
  for (var d = 0; d < j.length; d++) {
    orderItem = j[d];
    if (orderItem.itemType == "S0") {
      m.push(orderItem.itemId);
      if (orderItem.itemProp && orderItem.itemProp.Internal_Purchase && orderItem.itemProp.Internal_Purchase == "true") {
        h.push(8)
      } else {
        h.push(1)
      }
      k.push(orderItem.qty);
      n.push("");
      var e = [];
      if (orderItem.gifts && orderItem.gifts.length > 0) {
        for (var f = 0; f < orderItem.gifts.length; f++) {
          e.push(orderItem.gifts[f].sbomCode)
        }
      }
      l.push(e.join("-"));
      b.push(orderItem.operation)
    }
    if (orderItem.itemType == "S1") {
      m.push(orderItem.itemId);
      h.push(6);
      k.push(orderItem.qty);
      n.push(orderItem.mainItemid);
      l.push("");
      b.push(orderItem.operation)
    }
    if (orderItem.itemType == "S6") {
      m.push(orderItem.itemId);
      h.push(7);
      k.push(orderItem.qty);
      n.push(orderItem.mainItemid);
      l.push("");
      b.push(orderItem.operation)
    }
    if (orderItem.itemType == "B") {
      m.push(orderItem.itemId);
      if (orderItem.itemProp && orderItem.itemProp.Internal_Purchase && orderItem.itemProp.Internal_Purchase == "true") {
        h.push(9)
      } else {
        h.push(2)
      }
      k.push(orderItem.qty);
      n.push("");
      l.push("");
      b.push(orderItem.operation)
    }
    if (orderItem.itemType == "20") {
      m.push(orderItem.itemId);
      h.push(20);
      k.push(orderItem.qty);
      n.push(orderItem.mainItemid);
      l.push("");
      b.push(orderItem.operation)
    }
  }
  var c = {};
  c.sbs = m.join(",");
  c.types = h.join(",");
  c.qtys = k.join(",");
  c.ess = n.join(",");
  c.gfs = l.join(",");
  c.ops = b.join(",");
  return c
};
ec.minicart.click.send = function (e, g) {
  var f = $(e).attr("value"),
    c = $(e).attr("type"),
    b = 5;
  ec.minicart.checkboxInverse($(e).attr("value"));
  $("#button-minicart-go2confirm").show();
  $("#disbutton-minicart-go2confirm").hide();
  var b = 5;
  if ($("#icon-choose-" + f).hasClass("icon-choose") && $("#checkbox-" + f).attr("checked")) {
    b = 5
  } else {
    b = 6
  }
  var d = {};
  d.sbs = f;
  d.types = c;
  d.qtys = 1;
  d.ops = b;
  d.saleChannel = 1001;
  d.salePortal = 1;
  $.ajax({
    url: domainCart + "/newcart/update.json?t=" + new Date().getTime(),
    type: "GET",
    dataType: "jsonp",
    timeout: 10000,
    traditional: true,
    data: d,
    success: function (h) {
      g(h)
    }
  })
};
ec.minicart.selectedItemIsEmpty = function () {
  var b = $("#minicart-goods-list input[name='skuIds']:checked").length + $("#minicart-goods-list input[name='bundleIds']:checked").length;
  if (b == 0) {
    $("#header-cart-total").html(0);
    $("#micro-cart-totalPrice").html("&yen;&nbsp;0.00");
    $("#micro-cart-totalOriginPrice").html("");
    $("#button-minicart-go2confirm").hide();
    $("#disbutton-minicart-go2confirm").show();
    return true
  }
  return false
};
ec.minicart.checkboxInverse = function (b) {
  if ($("#icon-choose-" + b).hasClass("icon-choose")) {
    $("#icon-choose-" + b).removeClass("icon-choose").addClass("icon-choose-normal");
    $("#checkbox-" + b).attr("checked", false)
  } else {
    $("#icon-choose-" + b).removeClass("icon-choose-normal").addClass("icon-choose");
    $("#checkbox-" + b).attr("checked", true)
  }
};
ec.minicart.buildOrderItemReqArgList = function () {
  var b = $("#minicart-goods-list input[name='skuIds']:checked");
  var d = $("#minicart-goods-list input[name='bundleIds']:checked");
  var c = [];
  b.each(function () {
    var h = $(this).closest("li");
    var e = this.value;
    var u = $("#quantity-" + e, h).val();
    var o = $("#quantity-" + e, h).attr("data-type");
    var q = {};
    var s = {};
    var r = {};
    var v = {};
    var f = $('input[name="extendIds"]', h).val();
    if (f) {
      s.itemId = f;
      s.qty = u;
      s.itemType = "S1";
      s.mainItemid = e;
      c.push(s)
    }
    var l = $('input[name="accidentIds"]', h).val();
    if (l) {
      r.itemId = l;
      r.qty = u;
      r.itemType = "S6";
      r.itemProp = {
        accidentItem: e
      };
      r.mainItemid = e;
      c.push(r)
    }
    var n = $("#preferIds_" + e).attr("skuids");
    if (n) {
      var p = n.split(",");
      for (var k = 0; k < p.length; k++) {
        if (p[k] != "") {
          var t = {};
          t.itemId = p[k];
          t.qty = "1";
          t.itemType = "20";
          t.mainItemid = e;
          c.push(t)
        }
      }
    }
    if (u) {
      q.itemId = e;
      q.qty = u;
      if (o == "1") {
        q.itemType = "S0"
      }
      if (o == "8") {
        q.itemType = "S0";
        q.itemProp = {
          Internal_Purchase: "true"
        }
      }
      if (o == "2") {
        q.itemType = "B"
      }
      if (o == "9") {
        q.itemType = "B";
        q.itemProp = {
          Internal_Purchase: "true"
        }
      }
      var g = $("#gift_sbomCodes_" + e).val();
      if (g) {
        var m = [];
        var p = g.split(",");
        for (var k = 0; k < p.length; k++) {
          if (p[k] != "") {
            var j = {};
            j.sbomCode = p[k];
            m.push(j)
          }
        }
        q.gifts = m
      }
      c.push(q)
    }
  });
  d.each(function () {
    var e = $(this).closest("li");
    var i = this.value;
    var h = $("#quantity-" + i, e).val();
    var f = $("#quantity-" + i, e).attr("data-type");
    var g = {};
    if (h) {
      g.itemId = i;
      g.qty = h;
      if (f == "2") {
        g.itemType = "B"
      }
      if (f == "9") {
        g.itemType = "B";
        g.itemProp = {
          Internal_Purchase: "true"
        }
      }
      c.push(g)
    }
  });
  return c
};
ec.minicart.confirm = function () {
  var b = $("#minicart-goods-list input[name='skuIds']:checked");
  var i = $("#minicart-goods-list input[name='bundleIds']:checked");
  if (b.length == 0 && i.length == 0) {
    alert("请至少选中一个商品！");
    return
  }
  if (!ec.account.isLogin()) {
    window.location.href = $("#top-index-loginUrl").attr("href")
  }
  var f = [];
  var d = [];
  var e = [];
  var g = [];
  var c = [];
  b.each(function () {
    var m = $(this).closest("li");
    var k = this.value;
    var r = $(this).attr("data-scode");
    var y = $("#quantity-" + k, m).val();
    var s = $("#quantity-" + k, m).attr("data-type");
    var u = {};
    var w = {};
    var v = {};
    if (y) {
      u.itemId = r;
      u.qty = y;
      if (s == "1") {
        u.itemType = "S0"
      }
      if (s == "8") {
        u.itemType = "S0";
        u.itemProp = {
          Internal_Purchase: "true"
        }
      }
      var p = $('input[name="giftId"]', m);
      if (p.length > 0) {
        var j = [];
        p.each(function () {
          var z = {
            sbomCode: this.value
          };
          j.push(z)
        });
        u.gifts = j
      }
      c.push(u)
    }
    var l = $('input[name="extendIds"]', m).attr("data-scode");
    if (l) {
      w.itemId = l;
      w.qty = y;
      w.itemType = "S1";
      w.itemProp = {
        main_skucode: r
      };
      c.push(w)
    }
    var o = $('input[name="accidentIds"]', m).attr("data-scode");
    if (o) {
      v.itemId = o;
      v.qty = y;
      v.itemType = "S6";
      v.itemProp = {
        main_skucode: r
      };
      c.push(v)
    }
    var q = $("#preferIds_" + k).val();
    if (q) {
      var t = q.split(",");
      for (var n = 0; n < t.length; n++) {
        if (t[n] != "") {
          var x = {};
          x.itemId = t[n];
          x.mainSkuCode = r;
          x.qty = "1";
          x.itemType = "S0";
          x.itemSubType = "PREFER";
          c.push(x)
        }
      }
    }
  });
  i.each(function () {
    var j = $(this).closest("li");
    var n = this.value;
    var m = $("#quantity-" + n, j).val();
    var k = $("#quantity-" + n, j).attr("data-type");
    var l = {};
    if (m) {
      l.itemId = n;
      l.qty = m;
      if (k == "2") {
        l.itemType = "B"
      }
      if (k == "9") {
        l.itemType = "B";
        l.itemProp = {
          Internal_Purchase: "true"
        }
      }
      c.push(l)
    }
  });
  var h = ec.lang.json.stringify(c);
  setTimeout(function () {
    ec.cart.confirm(1, h)
  }, 500)
};
ec.pkg("ec.product");
ec.product.history = {
  load: function (d, c, b) {
    $.ajax({
      url: "/product/browsed/query.json",
      data: {
        size: c ? c : undefined,
        pid: b ? b : undefined
      },
      dataType: "json",
      success: function (e) {
        if (!e.success) {
          return
        }
        d(e.list || [])
      }
    })
  },
  add: function (c) {
    var b = new Image();
    b.src = "/product/browsed/add?id=" + c + "&_t=" + (new Date()).getTime();
    b = null
  },
  clear: function (c) {
    var b = new Image();
    b.src = "/product/browsed/clear?_t=" + (new Date()).getTime();
    b = null;
    if (c) {
      c()
    }
  }
};
ec.product.inventory = {
  _data: {},
  set: function (c, b) {
    this._data[c] = b
  },
  haveInventory: function (b) {
    return this._data[b]
  }
};
ec.pkg("ec.cart");
ec.cart.productTypeCorrespondence = function (b) {
  if (b == 1) {
    b = "S0"
  } else {
    if (b == 2) {
      b = "B"
    } else {
      if (b == 6) {
        b = "S1"
      } else {
        if (b == 7) {
          b = "S6"
        } else {
          if (b == 8) {
            b = "S0"
          } else {
            if (b == 9) {
              b = "B"
            } else {
              if (b == 20) {
                b = "20"
              } else {
                b = "S0"
              }
            }
          }
        }
      }
    }
  }
  return b
};
ec.cart.add = function (c, b) {
  var d = {};
  d.salePortal = c.salePortal;
  d.saleChannel = c.saleChannel;
  d.needResultset = c.needResultset;
  d.cartjson = c.cartjson;
  $.ajax({
    url: domainCart + "/newcart/add.json",
    dataType: "jsonp",
    timeout: 30000,
    traditional: true,
    data: d,
    success: function (e) {
      if (e.msg != "success") {
        if (b.errorFunction) {
          e.msg = "购物车繁忙，您可以选择立即下单";
          b.errorFunction(e)
        }
        return
      }
      if (b.successFunction) {
        ec.util.cookie.set("cartAdded", ec.util.cookie.get("cartId"));
        b.successFunction(e)
      }
    },
    error: function (i, h, g) {
      if (b.errorFunction) {
        var f = {};
        f.msg = h;
        f.msg = "购物车繁忙，您可以选择立即下单";
        b.errorFunction(f)
      }
    }
  })
};
ec.cart.getCartTotalNumber = function (c, b) {
  if (!ec.util.cookie.get("cartId") && !ec.account.isLogin()) {
    return
  }
  $.ajax({
    url: domainCart + "/newcart/shoppingCart/number.json?t=" + new Date().getTime() + "&saleChannel=1001&salePortal=1",
    dataType: "jsonp",
    timeout: 10000,
    success: function (d) {
      if (d.retcode == 0) {
        c(d, b)
      } else {
        c(null, b)
      }
    }
  })
};
ec.cart.getCartItemsInternal = function (c, b) {
  $.ajax({
    url: domainCart + "/newcart/shoppingCart.json?t=" + new Date().getTime() + "&saleChannel=1001&salePortal=1",
    dataType: "jsonp",
    timeout: 10000,
    success: function (d) {
      if (d.retcode == 0) {
        c(d, b)
      } else {
        c(null, b)
      }
    }
  })
};
ec.cart.getCartItems = function (e, b) {
  var d = ec.util.cookie.get("cartId");
  if (d && d.length > 0) {
    var c = ec.util.cookie.get("isValCas");
    if (c && "false" == c) {
      $.ajax({
        url: "/account/load",
        type: "POST"
      });
      c = ec.util.cookie.get("isValCas")
    }
    if (ec.account.isLogin() && ec.account.id && ec.account.loginName) {
      ec.cart.doCache2cart(ec.cart.getCartItemsInternal, e, b)
    } else {
      ec.cart.getCartItemsInternal(e, b)
    }
  } else {
    ec.cart.getCartItemsInternal(e, b)
  }
};
ec.cart.buildQueryData = function (f) {
  var j = [];
  var h = [];
  var c = [];
  var d = [];
  for (var g = 0; g < f.length; g++) {
    var b = f[g];
    if (b.skuId) {
      j.push(b.skuId)
    } else {
      if (b.bundleId) {
        j.push(b.bundleId)
      } else {
        continue
      }
    }
    h.push(b.productType);
    c.push(b.quantity);
    if (b.mainSkuId) {
      d.push(b.mainSkuId)
    } else {
      d.push("")
    }
  }
  var e = new Date();
  return {
    sbs: j.join(","),
    types: h.join(","),
    qtys: c.join(","),
    ess: d.join(","),
    t: e.getTime()
  }
};
ec.cart.getOnceCartInfo = function (b, e, c) {
  var d = ec.cart.buildQueryData(b);
  $.ajax({
    url: domainMain + "/order/shoppingCart/newCart.json",
    dataType: "jsonp",
    timeout: 10000,
    traditional: true,
    data: d,
    success: function (f) {
      if (c != null) {
        e(f, c)
      } else {
        if (!f.success || !f.cartInfo) {
          return
        } else {
          e(f)
        }
      }
    },
    error: function () {
      if (c != null) {
        var f = {};
        f.success = false;
        e(f, c)
      }
    }
  })
};
ec.cart.batchCount = 50;
ec.cart.getCartInfo = function (f, p) {
  if (!f || f.length == 0) {
    p({});
    return
  }
  if (f.length <= ec.cart.batchCount) {
    ec.cart.getOnceCartInfo(f, p)
  } else {
    var o = [];
    var b = [];
    var e = [];
    outer: for (var l = 0; l < f.length; l++) {
      var c = f[l];
      if (c.productType == 1) {
        e.push(c);
        if (e.length == ec.cart.batchCount) {
          o.push(e);
          e = []
        }
      } else {
        if (c.productType == 6) {
          for (var g = 0; g < o.length; g++) {
            var h = o[g];
            if (h[0].productType == 1) {
              for (var d = 0; d < h.length; d++) {
                if (h[d].skuId == c.mainSkuId) {
                  h.push(c);
                  continue outer
                }
              }
            }
          }
          for (var g = 0; g < e.length; g++) {
            if (e[g].skuId == c.mainSkuId) {
              e.push(c)
            }
          }
        } else {
          b.push(c);
          if (b.length == ec.cart.batchCount) {
            o.push(b);
            b = []
          }
        }
      }
    }
    if (b.length > 0) {
      if (b.length + e.length <= ec.cart.batchCount) {
        b.push(e);
        o.push(b)
      } else {
        o.push(b);
        o.push(e)
      }
    } else {
      if (e.length > 0) {
        o.push(e)
      }
    }
    var n = {};
    n.cartInfo = {};
    n.cartInfo.bundlerList = [];
    n.cartInfo.productList = [];
    n.cartInfo.couponList = [];
    n.cartInfo.premiumsList = [];
    n.cartInfo.totalOriginalPrice = 0;
    n.cartInfo.totalPrice = 0;
    n.limitstock = [];
    n.understock = [];
    var m = 0;
    for (var l = 0; l < o.length; l++) {
      var h = o[l];
      ec.cart.getOnceCartInfo(h, function (j, k) {
        m += 1;
        if (j.success && j.cartInfo) {
          if (j.cartInfo.bundlerList && j.cartInfo.bundlerList.length > 0) {
            n.cartInfo.bundlerList = n.cartInfo.bundlerList.concat(j.cartInfo.bundlerList)
          }
          if (j.cartInfo.productList && j.cartInfo.productList.length > 0) {
            n.cartInfo.productList = n.cartInfo.productList.concat(j.cartInfo.productList)
          }
          if (j.cartInfo.couponList && j.cartInfo.couponList.length > 0) {
            n.cartInfo.couponList = n.cartInfo.couponList.concat(j.cartInfo.couponList)
          }
          if (j.cartInfo.premiumsList && j.cartInfo.premiumsList.length > 0) {
            n.cartInfo.premiumsList = n.cartInfo.premiumsList.concat(j.cartInfo.premiumsList)
          }
          n.cartInfo.totalOriginalPrice += j.cartInfo.totalOriginalPrice;
          n.cartInfo.totalPrice += j.cartInfo.totalPrice;
          if (j.limitstock && j.limitstock.length > 0) {
            n.limitstock = n.limitstock.concat(j.limitstock)
          }
          if (j.understock && j.understock.length > 0) {
            n.understock = n.understock.concat(j.understock)
          }
        }
        if (m == o.length) {
          p(n)
        }
      }, l)
    }
  }
};
ec.cart.getCart = function (b) {
  ec.cart.getCartItems(ec.cart.getCartInfo, b)
};
ec.cart.getCartBaseInfo = function (b, c) {};
ec.cart.getCartBase = function (b) {
  ec.cart.getCartItems(ec.cart.getCartBaseInfo, b)
};
ec.cart.buildMicroCartReq = function (f) {
  var l = [];
  if (f && f.length > 0) {
    for (var k = 0; k < f.length; k++) {
      var c = f[k];
      var m = {};
      m.itemId = c.skuId;
      m.qty = c.quantity;
      if (c.productType == "1") {
        m.itemType = "S0";
        var b = [];
        if (c.giftCartList && c.giftCartList.length > 0) {
          for (var g = 0; g < c.giftCartList.length; g++) {
            var e = {
              sbomCode: c.giftCartList[g].skuId
            };
            b.push(e)
          }
        }
        m.gifts = b
      }
      if (c.productType == "8") {
        m.itemType = "S0";
        m.itemProp = {
          Internal_Purchase: "true"
        }
      }
      if (c.productType == "6") {
        m.itemType = "S1";
        m.itemProp = {
          main_skucode: c.mainSkuId
        }
      }
      if (c.productType == "7") {
        m.itemType = "S6";
        m.itemProp = {
          main_skucode: c.mainSkuId
        }
      }
      if (c.productType == "2") {
        m.itemId = c.bundleId;
        m.itemType = "B"
      }
      if (c.productType == "9") {
        m.itemId = c.bundleId;
        m.itemType = "B";
        m.itemProp = {
          Internal_Purchase: "true"
        }
      }
      l.push(m)
    }
  }
  var n = ec.lang.json.stringify(l);
  var d = new Date();
  var h = {};
  h.cartReqJson = n;
  h.t = d.getTime();
  return h
};
ec.cart.getMicroCartBaseInfo = function () {};
ec.cart.doCache2cart = function (b, f, c) {
  var e = ec.util.cookie.get("cartId");
  var d = ec.util.cookie.get("cartAdded");
  if (!d || d != e) {
    ec.util.cookie.set("cartId", null, {
      expires: -1,
      domain: ".vmall.com"
    });
    if (b) {
      b(f, c)
    }
    return
  }
  $.ajax({
    url: domainCart + "/newcart/cache2cart.json?saleChannel=1001&salePortal=1&t=" + new Date().getTime(),
    dataType: "jsonp",
    timeout: 10000,
    cache: false,
    success: function (g) {
      if (b) {
        b(f, c)
      }
    }
  })
};
ec.cart.getMicroCartTotalNumber = function (e) {
  var b = null;
  var d = ec.util.cookie.get("cartId");
  if (d && d.length > 0) {
    var c = ec.util.cookie.get("isValCas");
    if (c && "false" == c) {
      $.ajax({
        url: "/account/load",
        type: "POST"
      });
      c = ec.util.cookie.get("isValCas")
    }
    if (ec.account.isLogin()) {
      ec.cart.doCache2cart(ec.cart.getCartTotalNumber, e, b)
    } else {
      ec.cart.getCartTotalNumber(e, b)
    }
  } else {
    ec.cart.getCartTotalNumber(e, b)
  }
};
ec.cart.getMicroCartFromOrder = function (e) {
  var b = null;
  var d = ec.util.cookie.get("cartId");
  if (d && d.length > 0) {
    var c = ec.util.cookie.get("isValCas");
    if (c && "false" == c) {
      $.ajax({
        url: "/account/load",
        type: "POST"
      });
      c = ec.util.cookie.get("isValCas")
    }
    if (ec.account.isLogin()) {
      ec.cart.doCache2cart(ec.cart.getCartItemsInternal, e, b)
    } else {
      ec.cart.getCartItemsInternal(e, b)
    }
  } else {
    ec.cart.getCartItemsInternal(e, b)
  }
};
ec.cart.getTotal = function () {
  ec.cart.getMicroCartFromOrder(function (e) {
    var b = e.cartInfo,
      d = e.shopInfo,
      c = $("#minicart-pro-empty"),
      g = $("#minicart-pro-list-block"),
      f = $("#minicart-pro-settleup");
    if (ec.minicart.microCartTpl) {
      $("#header-cart-total,#micro-cart-total").html(b.totalNumber || 0);
      if (b.totalNumber > 0) {
        $("#micro-cart-totalPrice").html("&yen;&nbsp;" + b.totalPrice.toFixed(2));
        ec.minicart.processCheck(b);
        $("#minicart-pro-list").html(ec.minicart.microCartTpl.parse("microCartList", b));
        g.show();
        f.show();
        c.hide();
        if ((b.productList.length + b.bundlerList.length) > 5) {
          g.addClass("minicart-pro-list-scroll")
        } else {
          g.removeClass("minicart-pro-list-scroll")
        }
      } else {
        c.show();
        g.hide();
        f.hide()
      }
      if (d) {
        $("#toolbar-orderWaitingHandleCount").html(d.orderWaitingHandleCount).attr("class", (d.orderWaitingHandleCount <= 0) ? "hide" : "");
        $("#toolbar-couponCount").html(d.couponCount).attr("class", (d.couponCount <= 0) ? "hide" : "");
        $("#toolbar-newMsgCount").html(d.newMsgCount).attr("class", (d.newMsgCount <= 0) ? "hide" : "");
        $("#top-couponCount").html(d.couponCount);
        $("#top-newMsgCount").html(d.newMsgCount).attr("class", (d.newMsgCount <= 0) ? "hide" : "")
      }
    }
    if (e.enterpriseUser) {
      $("#preferential").html('<a  href="' + domainMain + '/member/enterprise" rel="nofollow">优惠内购</a>').show();
      $("#li-enterprise").html('<a href="' + domainMain + '/member/enterprise"><span>优惠内购</span></a>').show()
    }
  })
};
ec.cart.changeAdded = function (b) {
  var c = null;
  if (b && b.cartInfo && b.cartInfo.cartVO) {
    c = b.cartInfo.cartVO.totalNumber >= 0 ? b.cartInfo.cartVO.totalNumber : c
  }
  if (b) {
    c = b.cartNumber >= 0 ? b.cartNumber : c
  }
  if (c > 0) {
    ec.util.cookie.set("cartAdded", ec.util.cookie.get("cartId"))
  }
  if (c == 0) {
    ec.util.cookie.set("cartAdded", null)
  }
};
ec.cart.newDel = function (d, f, e) {
  if (!e) {
    ec.ui.loading.show({
      modal: false
    })
  }
  var b = new Date();
  d.t = b.getTime();
  var c = {
    data: d,
    dataType: "jsonp",
    timeout: 10000,
    timeoutFunction: function () {
      ec.ui.loading.hide();
      alert("操作超时，请重试！")
    },
    successFunction: function (g) {
      ec.cart.changeAdded(g);
      if ("0" != g.retcode) {
        ec.ui.loading.hide();
        ec.showError(g);
        return
      }
      if (f) {
        f(g)
      }
      ec.ui.loading.hide();
      return
    }
  };
  c.url = domainCart + "/newcart/del.json";
  new ec.ajax().get(c)
};
ec.cart.setRecover = function (b) {
  ec.util.cookie.set("cart-recover", b, {
    domain: ".vmall.com",
    path: "/"
  })
};
ec.cart.removeSkuFromRecover = function (c, e) {
  var b = ec.util.cookie.get("cart-recover");
  if (b) {
    var d = new RegExp("," + c + ";\d+,");
    b = b.replace(d, ",");
    ec.cart.setRecover(b)
  }
  if (e) {
    e(b)
  }
};
ec.cart.jumpToConfirm = function (b, i) {
  var f = [];
  var d = [];
  var e = [];
  var g = [];
  var c = [];
  b.each(function () {
    var m = $(this).parent();
    var k = $(this).attr("value");
    var q = $(this).attr("data-scode");
    var v = $("#quantity-" + k, m).val();
    var r = $("#quantity-" + k, m).attr("data-type");
    var s = {};
    var u = {};
    var t = {};
    var l = $('div[name="extendIds"]', m).attr("data-scode");
    if (l) {
      u.itemId = l;
      u.qty = v;
      u.itemType = "S1";
      u.itemProp = {
        main_skucode: q
      };
      c.push(u)
    }
    var o = $('div[name="accidentIds"]', m).attr("data-scode");
    if (o) {
      t.itemId = o;
      t.qty = v;
      t.itemType = "S6";
      t.itemProp = {
        main_skucode: q
      };
      c.push(t)
    }
    var p = $('input[name="preferId"]', m);
    if (p.length > 0) {
      p.each(function () {
        var w = {};
        if ($(this).attr("value")) {
          w.itemId = $(this).attr("value");
          w.qty = "1";
          w.itemType = "S0";
          w.itemSubType = "PREFER";
          w.mainSkuCode = $(this).attr("mainCode");
          c.push(w)
        }
      })
    }
    if (v) {
      s.itemId = q;
      s.qty = v;
      if (r == "1") {
        s.itemType = "S0"
      }
      if (r == "8") {
        s.itemType = "S0";
        s.itemProp = {
          Internal_Purchase: "true"
        }
      }
      var n = $('input[name="giftId"]', m);
      if (n.length > 0) {
        var j = [];
        n.each(function () {
          var w = {
            sbomCode: this.value
          };
          j.push(w)
        });
        s.gifts = j
      }
      c.push(s)
    }
  });
  i.each(function () {
    var j = $(this).parent();
    var n = $(this).attr("value");
    var m = $("#quantity-bundle-" + n, j).val();
    var k = $("#quantity-bundle-" + n, j).attr("data-type");
    var l = {};
    if (m) {
      l.itemId = n;
      l.qty = m;
      if (k == "2") {
        l.itemType = "B"
      }
      if (k == "9") {
        l.itemType = "B";
        l.itemProp = {
          Internal_Purchase: "true"
        }
      }
      c.push(l)
    }
  });
  var h = ec.lang.json.stringify(c);
  setTimeout(function () {
    ec.cart.confirm(1, h)
  }, 500)
};
ec.cart.confirm = function (d, e, c) {
var b = $('<form action="' + domainMain + '/order/confirmcart" method="post"></form>');
b.append('<input name="orderReqJson" type="hidden" value='
  '+e+"' / > ");if(d){b.append('<input name="
  state " type="
  hidden " value="
  '+d+'
  " />')}if(c){b.append('<input name="
  orderTag " type="
  hidden " value="
  '+c+'
  " />')}$("
  body ").append(b);b.submit()};ec.cart.allConfirm=function(e,f,d,b){var c=$('<form action="
  '+domainMain+b+'
  " method="
  post "></form>');c.append('<input name="
  orderReqJson " type="
  hidden " value=''+f+"
  ' />");if(e){c.append(' < input name = "state"
  type = "hidden"
  value = "'+e+'" / > ')}if(d){c.append(' < input name = "orderTag"
  type = "hidden"
  value = "'+d+'" / > ')}$("body").append(c);c.submit()};ec.cart.coverOrderConfirm=function(e,b,d,g,f,h){var c=$(' < form action = "'+domainMain+'/order/coverOrderConfirm"
  method = "post" > < /form>');c.append('<input name="UIDesignID" type="hidden" value=''+e+"' / > ");if(b){c.append('<input name="
  sbomCode " type="
  hidden " value="
  '+b+'
  " />')}if(d){c.append('<input name="
  coverServSKU " type="
  hidden " value="
  '+d+'
  " />')}if(g){c.append('<input name="
  quantity " type="
  hidden " value="
  '+g+'
  " />')}if(f){c.append('<input name="
  extendServiceSKU " type="
  hidden " value="
  '+f+'
  " />')}if(h){c.append('<input name="
  exceptionServiceSKU " type="
  hidden " value="
  '+h+'
  " />')}$("
  body ").append(c);c.submit()};ec.pkg("
  ec.base ");ec.base.getTotal=function(){$.ajax({url:domainMain+" / page / totalInfo.json ",dataType:"
  jsonp ",success:function(c){if(c.enterpriseUser){$("#
  preferential ").html('<a href="
  '+domainMain+' / member / enterprise " rel="
  nofollow ">优惠内购</a>').show();$("#
  li - enterprise - preferential ").html('<a href="
  '+domainMain+' / member / enterprise "><span>优惠内购</span></a>').show();$("#
  li - enterprise ").html('<a href="
  '+domainMain+' / member / enterprise "><span>优惠内购</span></a>').show()}if(ec.account.isLogin()){var b=ec.util.cookie.get("
  isAuthCust ");if("
  true "==b){$("#
  authentication ").html("
  ");$("#
  authentication ").html('<i class="
  icon - authentication icon - authentication - success "></i>&nbsp;');$("#
  authentication_yes ").removeClass().addClass("
  ");$("#
  authentication_no ").removeClass().addClass("
  hide ")}else{$("#
  authentication ").html("
  ");$("#
  authentication ").html('<i class="
  icon - authentication icon - authentication - not "></i>&nbsp;');$("#
  authentication_yes ").removeClass().addClass("
  hide ");$("#
  authentication_no ").removeClass().addClass("
  ");$("#
  authentication_no ").html("
  ");$("#
  authentication_no ").html('<i class="
  link - non - validated "></i>未实名认证</a>')}}}})};var topSearchKeyword="
  ";function search(c){var b=$("#
  search - kw ").val();if(ec.util.isEmpty(b)){return false}b=$.trim(b);window.location.href=" / search ? keyword = "+encodeURIComponent(b);return false}(function(){var b;ec.ready(function(){$("#
  ec_ui_confirm_no ").unbind("
  click ").click(function(){$("#
  ec_ui_confirm ").hide()});$("#
  ec_ui_confirm_new_no ").unbind("
  click ").click(function(){$("#
  ec_ui_confirm_new ").hide()});$("#
  ec_ui_tips_yes ").unbind("
  click ").click(function(){$("#
  ec_ui_tips ").hide()})});ec.ui.confirm=function(j,e){var d=ec.ui.confirm.caller,c=d.arguments;if(b!=null&&c[c.length-1]==b){b=null;return true}$("#
  ec_ui_confirm_msg ").html(e);var n=$(j),g=$("#
  ec_ui_confirm "),k=n.offset(),p=k.top-g.outerHeight(true)-5,f=k.left-g.outerWidth(true)/2,o=[],h=c.length,m=c.callee.length;for(var l=0;l<h;l++){o.push(c[l])}o[m]=(b=(new Date()).getTime());$("#
  ec_ui_confirm_yes ").unbind("
  click ").click(function(){$("#
  ec_ui_confirm ").hide();d.apply(this,o);o=null});g.css({top:p,left:f,position:"
  absolute "}).show();g.css("
  z - index ","
  999 ");return false};ec.ui.confirmNew=function(l,e,g,q){var d=ec.ui.confirmNew.caller,c=d.arguments;if(b!=null&&c[c.length-1]==b){b=null;return true}$("#
  ec_ui_confirm_new_msg ").html(e);if(g){$("#
  ec_ui_confirm_new_yes ").attr("
  title ",g);$("#
  ec_ui_confirm_new_yes ").html(" < span > "+g+" < /span>")}if(q){$("#ec_ui_confirm_new_no").attr("title",q);$("#ec_ui_confirm_new_no").html("<span>"+q+"</span > ")}var o=$(l),h=$("#
  ec_ui_confirm_new "),k=o.offset(),r=k.top-h.outerHeight(true)-5,f=k.left-h.outerWidth(true)/9,p=[],j=c.length,n=c.callee.length;for(var m=0;m<j;m++){p.push(c[m])}p[n]=(b=(new Date()).getTime());$("#
  ec_ui_confirm_new_yes ").unbind("
  click ").click(function(){$("#
  ec_ui_confirm_new ").hide();d.apply(this,p);p=null});h.css({top:r,left:f,position:"
  absolute "}).show();return false};ec.ui.tips=function(i,h){$("#
  ec_ui_tips_msg ").html(h);var d=$(i),c=$("#
  ec_ui_tips "),g=d.offset(),f=g.top-c.outerHeight(true)-5,e=g.left-c.outerWidth(true)/2;c.css({top:f,left:e,position:"
  absolute "}).show()}})();$.extend(ec.form.validator.defaults,{errorClass:"
  error ",autoFocus:false,errorFunction:function(d,b){var c="
  icon - error ",e=b.msg[b.type]||b.msg["
  default "];e=(e.length<=0)?" & nbsp;
  ":e;switch(b.type){case"
  require ":c="
  icon - warn ";break}if(b.msg_ct){$(b.msg_ct).html(" < span class = 'vam "+c+"' > "+e+" < /span>")}else{var f=(d.attr("id")||d.attr("name"))+"-msg";$("#"+f).remove();d.after("<span id='"+f+"' class='vam "+c+"'>"+e+"</span > ")}if(b.autoFocus){d.focus()}},successFunction:function(c,b){if(b.msg_ct){$(b.msg_ct).html("
  ")}else{$("#
  "+(c.attr("
  id ")||c.attr("
  name "))+" - msg ").remove()}}});ec.form.validator.register("
  mobile ",function(c,b){if(b.allowEmpty&&ec.util.isEmpty(c)){return true}if(c.length<11){return false}return/^(+|00)?((86)?(1[34578])[0-9]{9}|852[965][0-9]{7})$/.test(c)});ec.form.validator.register("
  phone ",function(c,b){if(b.allowEmpty&&ec.util.isEmpty(c)){return true}if(c.length<7){return false}return/^((0[0-9]{2,3}-)?[2-9][0-9]{6,7}|((00852|+852)-)?([2-3][0-9]{7}))+(-[0-9]{1,4})?$/.test(c)});ec.form.validator.register("
  mobleOrPhone ",function(c,b){if(b.allowEmpty&&ec.util.isEmpty(c)){return true}if(c.length<11){return false}return/(^((0[0-9]{2,3}-)?[2-9][0-9]{6,7}|((00852|+852)-)?([2-3][0-9]{7}))+(-[0-9]{1,4})?$)|(^(+|00)?((86)?(1[34578])[0-9]{9}|852[965][0-9]{7})$)/.test(c)});ec.form.validator.register("
  addressCheck ",function(c,b){if(b.allowEmpty&&ec.util.isEmpty(c)){return true}if(c=="
  选择省 - 市 - 区 - 街道 "){return false}return true});ec.form.validator.register("
  addressConfirmCheck ",function(){if($("#
  current - address ").html()=="
  选择省 - 市 - 区 - 街道 "){return false}else{var d=$("#
  myAddress - form ");var b=d.find("
  input[name = 'province']
  ").val(),f=d.find("
  input[name = 'city']
  ").val(),e=d.find("
  input[name = 'district']
  ").val(),g=d.find("
  input[name = 'street']
  ").val(),c=d.find("
  input[name = 'needL4Addr']
  ").val();if("
  "!=b&&"
  "!=f&&"
  "!=e){if(c=="
  true "&&g=="
  "){return false}else{return true}}else{return false}}return true});ec.form.validator.register("
  addressContractCheck ",function(){var c=$("#
  order - address - add - form ");var b=c.find("
  select[name = 'province'] option : selected ").val(),e=c.find("
  select[name = 'city'] option: selected ").val(),d=c.find("
  select[name = 'district'] option: selected ").val(),f=c.find("
  select[name = 'street'] option: selected ").val();if("
  "!=b&&"
  "!=e&&"
  "!=d){if("
  "==f){return false}else{return true}}else{return false}});ec.form.validator.register("
  forbidChar ",function(c,b){if(b.allowEmpty&&ec.util.isEmpty(c)){return true}c=c.replace(" * ","
  @ "),c=c.replace("--","
  @ "),c=c.replace(" / ","
  @ "),c=c.replace(" + ","
  @ "),c=c.replace("
  '","@"),c=c.replace("\","@"),c=c.replace("$","@"),c=c.replace("^","@"),c=c.replace(".","@"),c=c.replace(";","@"),c=c.replace("<","@"),c=c.replace(">","@"),c=c.replace('
  "',"
  @ "),c=c.replace(" = ","
  @ "),c=c.replace(" {
    ","
    @ "),c=c.replace("
  }
  ","
  @ ");c=c.replace(" % ","
  @ ");c=c.replace("~","
  @ ");c=c.replace(" & ","
  @ ");if(c.search(new RegExp("
  @ "))!=-1){return false}return true});ec.form.validator.register("
  invoiceForbidChar ",function(e,c){if(c.allowEmpty&&ec.util.isEmpty(e)){return true}e=e.replace("--"," & ");var d=/^[^\*\+\\/\$\^\;<>" = \ {\} % ~ & ] + $ / g;
var b = d.test(e);
if (!b) {
  return false
}
return b
});
ec.form.validator.register("forbidChar2", function (d, c) {
  if (c.allowEmpty && ec.util.isEmpty(d)) {
    return true
  }
  var b = /^[^<>\(\)'"]+$/g;
  return b.test(d)
});
ec.ui.number = function (b, c) {
  var d = {
      max: null,
      min: null,
      showButton: true,
      minusBtn: '<a class="icon-minus vam" href="javascript:;"><span>-</span></a>',
      plusBtn: '<a class="icon-plus vam" href="javascript:;"><span>+</span></a>'
    },
    e = $(b),
    c = $.extend(d, c),
    f = function (g) {
      var i = g.which,
        h = parseInt(this.value, 10),
        j = (h < 1) ? 1 : h;
      if ((i < 37 || i > 40) && i != 8 && i != 46) {
        if (j > c.max || j < c.min) {
          g.preventDefault();
          return false
        } else {
          if ((i < 48 || i > 57) && (i < 96 || i > 105) && i != 9) {
            g.preventDefault();
            return false
          }
        }
      }
    };
  e.each(function () {
    var i = $.extend({}, c),
      g = $(this).css("ime-mode", "disabled");
    var h = g.attr("max");
    if (h) {
      c.max = i.max = parseInt(h, 10) || i.max
    }
    h = g.attr("min");
    if (h) {
      c.min = i.min = parseInt(h, 10) || i.min
    }
    if (i.showButton) {
      var k = $(i.minusBtn).click(function () {
          var l = g.val() || 0,
            m = parseInt(l, 10) - 1;
          if (typeof (i.min) == "number" && m < i.min) {
            return
          }
          g.val(m).trigger("blur")
        }),
        j = $(i.plusBtn).click(function () {
          var l = g.val() || 0,
            m = parseInt(l, 10) + 1;
          if (typeof (i.max) == "number" && m > i.max) {
            return
          }
          g.val(m).trigger("blur")
        });
      g.after(j).before(k)
    }
    g.data("ovalue", g.val() || 0).keydown(f).keyup(function () {
      var l = parseInt(this.value || 0);
      if (typeof (i.min) == "number" && l < i.min) {
        this.value = i.min;
        return
      } else {
        if (typeof (i.max) == "number" && l > i.max) {
          this.value = i.max;
          return
        }
      }
    }).blur(function () {
      if (typeof i.onchange === "function") {
        var l = g.data("ovalue"),
          m = this.value || 0,
          n = parseInt(m, 10) - parseInt(l, 10);
        if (n == 0) {
          return
        }
        g.data("ovalue", m);
        i.onchange.call(this, m, n)
      }
    })
  })
};
ec.ui.countdown = function (e, m) {
  var g = $(e),
    c = g.data("countdown"),
    l = 0,
    j, k, f = m.now.getTime() - new Date().getTime(),
    d = 0,
    i = function () {
      if (l >= m.times.length) {
        return false
      }
      j = m.times[l];
      l++;
      return true
    },
    h = function () {
      d = Math.round((j.parseDate("yyyy-MM-dd HH:mm:ss").getTime() - new Date().getTime() - f) / 1000);
      d = d <= 0 ? 0 : d;
      return d
    },
    b = function () {
      d--;
      if (d <= 0) {
        d = 0
      }
      k = {
        day: Math.floor(d / (24 * 60 * 60)),
        hour: (m.html.indexOf("{#day}") >= 0) ? Math.floor(d / 60 / 60) % 24 : Math.floor(d / 60 / 60),
        minute: Math.floor(d / 60) % 60,
        second: d % 60
      };
      var n = m.html.replace(/{#day}/g, k.day).replace(/{#hours}/g, k.hour > 9 ? k.hour : "0" + k.hour).replace(/{#minutes}/g, k.minute > 9 ? k.minute : "0" + k.minute).replace(/{#seconds}/g, k.second > 9 ? k.second : "0" + k.second);
      g.html(n);
      return (d <= 0) ? false : true
    };
  if (!m.times) {
    m.times = [m.endTime]
  }
  clearInterval(c);
  while (i()) {
    if (h() <= 0) {
      continue
    }
    break
  }
  if (!b()) {
    return
  }
  c = setInterval(function () {
    if (!b()) {
      if (m.callback) {
        m.callback(m)
      }
      if (!i()) {
        clearInterval(c)
      } else {
        h()
      }
    }
  }, 1000);
  g.data("countdown", c)
};
(function () {
  var c = $(window),
    j = false,
    b = document.compatMode == "CSS1Compat" ? document.documentElement : document.body,
    g = 0,
    d = 0,
    h, e = [],
    f, i = function (k) {
      var l = k.offset().top - 300,
        m = l + k.height() + 600;
      if ((l >= g && l <= d) || (m >= g && m <= d)) {
        k.attr("src", k.attr("data-lazy-src"));
        k.removeAttr("data-lazy-src");
        return true
      }
      return false
    };
  _bindEvent = function () {
    var k = function () {
        clearTimeout(f);
        f = setTimeout(function () {
          g = c.scrollTop();
          d = g + h;
          var m;
          for (var n = 0; n < e.length; n++) {
            m = e[n];
            if (i(m)) {
              e.splice(n, 1);
              n--
            }
          }
          if (!e || e.length == 0) {
            c.unbind("scroll", k);
            c.unbind("resize", l)
          }
        }, 100)
      },
      l = function (m) {
        h = b.clientHeight
      };
    c.bind("scroll", k);
    c.bind("resize", l);
    h = b.clientHeight;
    g = c.scrollTop();
    d = g + h
  };
  ec.ui.lazyLoad = function (k) {
    if (!j) {
      _bindEvent();
      j = true
    }
    $(k).each(function () {
      if (this.tagName != "IMG") {
        return
      }
      var l = $(this);
      if (l.attr("data-lazy-src")) {
        if (!i(l)) {
          l.attr("src", ol.libPath + "../../images/echannel/loading/mask.png");
          e.push(l)
        }
      }
    })
  }
})();
ec.ready(function () {
  ec.ui.lazyLoad($("body").children(".home-channel-menu,.layout,.g,.home-channel-container,.channel-floor,.home-channel-floor").find("img"));
  ec.ui.hrefSetTime()
});
ec.showError = function (b) {
  if (b.code == "login") {
    alert("登录超时，请重新登录");
    location.reload();
    return false
  }
  alert(b.msg)
};
ec.load("ajax", {
  loadType: "lazy"
});
(function () {
  var b = function () {
    var f = ec.form.validator.bind,
      e = $("#surveryContent"),
      c = $("#surveryContact"),
      d = $("#surveryVerify");
    f(e, {
      type: ["require", "length", "forbidChar"],
      validOnChange: true,
      msg_ct: "#errMsg",
      max: 200,
      min: 5,
      msg: {
        require: "您还没有输入反馈信息哦",
        length: "反馈信息内容请控制在5~200个字符之间",
        forbidChar: "反馈信息里包含非法字符"
      }
    });
    f(c, {
      type: ["length"],
      validOnChange: true,
      msg_ct: "#errMsg",
      min: 2,
      max: 100,
      msg: {
        length: "请输入正确的联系方式"
      }
    });
    f(d, {
      type: ["require"],
      validOnChange: true,
      msg_ct: "#errMsg",
      msg: {
        require: "请输入验证码"
      }
    });
    if (ec.account.isLogin()) {
      c.val(ec.util.escapeHtml(ec.account.email) || ec.util.escapeHtml(ec.account.mobile) || ec.account.loginName)
    }
    ec.form.input.label(c, "选填，邮箱或者商城账户");
    ec.form.input.label(e, "谢谢您的宝贵建议，我们将不断改进")
  };
  ec.survery = {
    open: function () {
      if (b) {
        b();
        b = null
      }
      var h = $("#survery-box");
      var d = $(window).width();
      var g = $(window).height();
      var f = h.width();
      var c = h.height();
      var e = document.createElement("div");
      e.className = "mask-new";
      e.style.width = d + "px";
      e.style.height = g + "px";
      e.style.background = "#000";
      e.style.position = "fixed";
      e.style.top = 0;
      e.style.left = 0;
      e.style.zIndex = 499;
      e.style.opacity = 0.4;
      e.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
      document.body.appendChild(e);
      ec.survery.reloadCode();
      $("#survery-box").css({
        position: "fixed",
        left: (d / 2 - f / 2) + "px",
        top: (g / 2 - c / 2) + "px",
        "z-index": 999
      }).show();
      $(window).resize(function () {
        d = $(window).width();
        g = $(window).height();
        $("#survery-box").css({
          left: (d / 2 - f / 2) + "px",
          top: (g / 2 - c / 2) + "px"
        })
      })
    },
    close: function () {
      ol.ui.masker.unmask();
      $(".mask-new").remove();
      $("#survery-box").hide()
    },
    submit: function () {
      var c = $("#form-feedback");
      if (!ec.form.validator(c, true)) {
        return false
      }
      $.ajax({
        type: "get",
        url: domainMain + "/feedback.json",
        dataType: "jsonp",
        timeout: 10000,
        async: true,
        data: {
          type: $("#surverytype").val(),
          content: $("#surveryContent").val(),
          contact: $("#surveryContact").val(),
          code: $("#surveryVerify").val()
        },
        success: function (d) {
          if (!d.success) {
            $("#errMsg").html('<span class="vam icon-warn">提交失败，' + d.msg + "</span>");
            return
          }
          alert("提交成功，华为商城感谢您的宝贵建议！");
          ec.survery.close();
          $("#surveryContent,#surveryVerify").val("");
          return
        }
      });
      return false
    },
    reloadCode: function () {
      gid("surveryVerifyImg").src = domainMain + "/feedback/randomCode?_t=" + (new Date()).getTime()
    }
  }
})();
$(function () {
  var d = $(window),
    e, c = $("#hungBar-top"),
    b = function () {
      c.stop();
      if (d.scrollTop() > 1200) {
        c.fadeTo(20, 1)
      } else {
        c.fadeOut(20)
      }
      e = null
    };
  d.scroll(function () {
    e = setTimeout(b, 50)
  });
  b()
});
(function () {
  ec.ui.hrefSetTime = function () {
    var c = (new Date()).getTime();
    try {
      $("a[timeType=timestamp]").each(function () {
        var d = $(this);
        d.attr("href", d.attr("href").replace(/timestamp/g, c))
      })
    } catch (b) {}
  }
})();
ec.pkg("ec.encipher");
ec.encipher.base = 10;
ec.encipher.bigPowMod = function (f, e, g) {
  f = str2bigInt(f, ec.encipher.base);
  e = str2bigInt(e, ec.encipher.base);
  g = str2bigInt(g, ec.encipher.base);
  var d = powMod(f, e, g);
  d = bigInt2str(d, ec.encipher.base);
  return d
};
ec.encipher.randomInt = function (c) {
  var b = randBigInt(c, 0);
  return bigInt2str(b, ec.encipher.base)
};
ec.encipher.getServerKey = function () {
  $.ajax({
    type: "get",
    url: "/system/getKey.json?t=" + new Date().getTime(),
    async: false,
    dataType: "json",
    timeout: 10000,
    success: function (b) {
      if (!(b.success)) {
        return
      }
      ec.util.cookie.set("sc_p", b.pubkey)
    }
  })
};
ec.encipher.getEncryptData = function (c, e, k) {
  var m = "";
  var h = "13232376895198612407547930718267435757728527029623408872245156039757713029036368719146452186041204237350521785240337048752071462798273003935646236777459223",
    l = "5421644057436475141609648488325705128047428394380474376834667300766108262613900542681289080713724597310673074119355136085795982097390670890367185141189796",
    j = ec.encipher.randomInt(128),
    d = ec.encipher.bigPowMod(l, j, h),
    f = ec.util.cookie.get("sc_p"),
    i, g;
  if (e == "" || e == null) {
    g = c + "?pubkey=" + d + "&seType=r&t=" + new Date().getTime()
  } else {
    g = c + "?argument=" + e + "&pubkey=" + d + "&seType=r&t=" + new Date().getTime()
  }
  $.ajax({
    type: "get",
    url: g,
    dataType: "json",
    async: false,
    timeout: 10000,
    success: function (b) {
      if (!b.success) {
        return
      }
      i = ec.encipher.bigPowMod(f, j, h);
      m = k(b.data, i)
    }
  });
  return m
};
ec.encipher.getKey = function (h) {
  var e = "13232376895198612407547930718267435757728527029623408872245156039757713029036368719146452186041204237350521785240337048752071462798273003935646236777459223",
    f = "5421644057436475141609648488325705128047428394380474376834667300766108262613900542681289080713724597310673074119355136085795982097390670890367185141189796",
    c = ec.encipher.randomInt(128),
    g = ec.encipher.bigPowMod(f, c, e),
    d;
  $.ajax({
    type: "get",
    url: domainShoppingConfig + "/member/smyAddresses.json?pubkey=" + g + "&seType=r&t=" + new Date().getTime(),
    dataType: "jsonp",
    async: true,
    timeout: 10000,
    success: function (b) {
      if (!b.success) {
        return
      }
      ec.util.cookie.set("sc_p", b.pubkey);
      d = ec.encipher.bigPowMod(b.pubkey, c, e);
      h(b.shoppingConfigList, b.randomFlag, d)
    }
  })
};
ec.encipher.encrypt = function (i) {
  var e = "13232376895198612407547930718267435757728527029623408872245156039757713029036368719146452186041204237350521785240337048752071462798273003935646236777459223",
    h = "5421644057436475141609648488325705128047428394380474376834667300766108262613900542681289080713724597310673074119355136085795982097390670890367185141189796",
    c = ec.encipher.randomInt(128),
    j = ec.encipher.bigPowMod(h, c, e),
    f = ec.util.cookie.get("sc_p"),
    d = ec.encipher.bigPowMod(f, c, e);
  if (d.length > 16) {
    d = d.substring(0, 16)
  }
  var g = rc4_str_base64(d, i);
  return {
    val: g,
    pubkey: j
  }
};
ec.encipher.decrypt = function (c, b) {
  if (b.length > 16) {
    b = b.substring(0, 16)
  }
  return rc4_base64_str(b, c)
};
ec.pkg("ec.addr");
ec.addr.list = function (b) {
  $.ajax({
    type: "get",
    url: domainShoppingConfig + "/member/myAddresses/list.json",
    dataType: "jsonp",
    async: true,
    timeout: 10000,
    success: function (c) {
      if (!c.success) {
        return
      }
      if (c.shoppingConfigList.length == 0) {
        $("#base-table").find(".report-errors").show()
      } else {
        $("#base-table").find(".report-errors").hide()
      }
      b(c.shoppingConfigList, c.randomFlag)
    }
  })
};
ec.addr.save = function (c, e) {
  var m = $(c);
  var r = m.find("input[name=id]").val();
  var g = "/member/myAddresses/add.json";
  var o = "post";
  var b = m.find("input[name=province]").val();
  var t = m.find("input[name=city]").val();
  var s = m.find("input[name=district]").val();
  var n = m.find("input[name=street]").val();
  var l = m.find("input[name='needL4Addr']").val();
  var j = m.find("input[name=mobile]");
  var p = m.find("input[name=phone]");
  if (j.hasClass("error") || p.hasClass("error")) {
    return false
  }
  if (!ec.form.validator(m, false)) {
    return false
  }
  var d = $.trim(m.find("input[name=mobile]").val());
  var h = $.trim(m.find("input[name=phone]").val());
  if (ec.util.isEmpty(d)) {
    return false
  }
  if (e.afterCheck) {
    e.afterCheck(r)
  }
  if (e.type != "add") {
    g = "/member/myAddresses/modify/" + r + ".json"
  }
  var i = m.find("input[name=consignee]").val();
  var f = m.find("input[name=address],textarea[name=address]").val();
  var k = m.find("input[name=zipCode]").val();
  var q = m.find("input[name=randomFlag]").val();
  var v = {};
  v.consignee = i;
  v.province = b;
  v.city = t;
  v.district = s;
  v.street = n;
  v.address = f;
  v.zipCode = k;
  v.mobile = d;
  v.phone = h;
  v.randomFlag = q;
  var u = m.find("input[name=defaultFlag]");
  if (u.length == 1 && u[0].checked && !u[0].disabled) {
    v.defaultFlag = u.val()
  }
  v.t = new Date().getTime();
  new ec.ajax().get({
    url: domainShoppingConfig + g + "?_method=" + o,
    data: v,
    dataType: "jsonp",
    timeout: 20000,
    timeoutFunction: function () {
      alert("保存超时，请重试！")
    },
    beforeSendFunction: ec.ui.loading.show,
    afterSendFunction: ec.ui.loading.hide,
    successFunction: function (w) {
      if (!w.success) {
        ec.showError(w);
        return
      }
      if (e.successFunction) {
        e.successFunction(w.shoppingConfig, c)
      }
    }
  });
  return false
};
ec.addr.setDefault = function (d, b) {
  var c = ec.util.cookie.get("sc_b");
  new ec.ajax().get({
    url: domainShoppingConfig + "/member/myAddresses/default.json?id=" + d + "&_method=PUT&t=" + new Date().getTime(),
    dataType: "jsonp",
    timeout: 20000,
    timeoutFunction: function () {
      alert("操作超时，请重试！")
    },
    beforeSendFunction: function () {
      ec.ui.loading.show({
        modal: false
      })
    },
    afterSendFunction: ec.ui.loading.hide,
    successFunction: function (e) {
      if (!e.success) {
        ec.showError(e);
        return
      }
      if (b.successFunction) {
        b.successFunction(d)
      }
    }
  })
};
ec.addr.getAll = function (b) {
  new ec.ajax().get({
    url: domainShoppingConfig + "/member/myAddresses.json",
    dataType: "jsonp",
    timeout: 20000,
    timeoutFunction: function () {
      alert("操作超时，请重试！")
    },
    beforeSendFunction: function () {
      ec.ui.loading.show({
        modal: false
      })
    },
    afterSendFunction: ec.ui.loading.hide,
    successFunction: function (c) {
      if (!c.success) {
        ec.showError(c);
        return
      }
      if (b.successFunction) {
        b.successFunction(c)
      }
    }
  })
};
ec.addr.del = function (c, b) {
  new ec.ajax().get({
    url: domainShoppingConfig + "/member/myAddresses/" + c + ".json?_method=delete",
    dataType: "jsonp",
    timeout: 10000,
    timeoutFunction: function () {
      alert("读取超时，请重试！")
    },
    beforeSendFunction: ec.ui.loading.show,
    afterSendFunction: ec.ui.loading.hide,
    successFunction: function (d) {
      if (!d.success) {
        ec.showError(d);
        if (d.code == "default") {
          if (b.deleteDefault) {
            b.deleteDefault(c)
          }
        }
        return
      }
      if (b.successFunction) {
        b.successFunction(c)
      }
    }
  })
};

function base64_encode(f) {
  var b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var d, c = "",
    e = f.length;
  for (d = 0; d < e - 2; d += 3) {
    c += b.charAt(f.charCodeAt(d) >>> 2);
    c += b.charAt(((f.charCodeAt(d) & 3) << 4) | (f.charCodeAt(d + 1) >>> 4));
    c += b.charAt(((f.charCodeAt(d + 1) & 15) << 2) | (f.charCodeAt(d + 2) >>> 6));
    c += b.charAt(f.charCodeAt(d + 2) & 63)
  }
  if (e % 3 === 2) {
    c += b.charAt(f.charCodeAt(d) >>> 2);
    c += b.charAt(((f.charCodeAt(d) & 3) << 4) | (f.charCodeAt(d + 1) >>> 4));
    c += b.charAt(((f.charCodeAt(d + 1) & 15) << 2));
    c += "="
  } else {
    if (e % 3 === 1) {
      c += b.charAt(f.charCodeAt(d) >>> 2);
      c += b.charAt(((f.charCodeAt(d) & 3) << 4));
      c += "=="
    }
  }
  return c
}

function rc4_key(g) {
  var e = Array(256);
  var f = Array(256);
  var d, b, c;
  for (d = 0; d < 256; d++) {
    e[d] = g.charCodeAt(d % g.length);
    f[d] = d
  }
  for (d = 0, b = 0; d < 256; d++) {
    b = (b + f[d] + e[d]) % 256;
    c = f[d];
    f[d] = f[b];
    f[b] = c
  }
  return f
}

function rc4_do(h, g) {
  var f = 0,
    d = 0,
    e;
  for (var b = 0; b < h.length; b++) {
    var f = (f + 1) % 256;
    var d = (d + g[f]) % 256;
    e = g[f];
    g[f] = g[d];
    g[d] = e;
    var c = (g[f] + (g[d] % 256)) % 256;
    h[b] = h[b] ^ g[c]
  }
  return h
}

function rc4_str(f, e) {
  e = decodeURIComponent(e);
  var c = rc4_key(f);
  var d = Array(e.length);
  for (var b = 0; b < e.length; b++) {
    d[b] = e.charCodeAt(b)
  }
  rc4_do(d, c);
  for (var b = 0; b < d.length; b++) {
    d[b] = String.fromCharCode(d[b])
  }
  return encodeURIComponent(d.join(""))
}

function rc4_str_base64(f, e) {
  e = encodeURIComponent(e);
  var c = rc4_key(f);
  var d = Array(e.length);
  for (var b = 0; b < e.length; b++) {
    d[b] = e.charCodeAt(b)
  }
  rc4_do(d, c);
  for (var b = 0; b < d.length; b++) {
    d[b] = String.fromCharCode(d[b])
  }
  return base64_encode(d.join(""))
}

function base64_decode(j) {
  var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  var d, c, b, n, m, l, k, o, h = 0,
    p = 0,
    f = "",
    g = [];
  if (!j) {
    return j
  }
  j += "";
  do {
    n = e.indexOf(j.charAt(h++));
    m = e.indexOf(j.charAt(h++));
    l = e.indexOf(j.charAt(h++));
    k = e.indexOf(j.charAt(h++));
    o = n << 18 | m << 12 | l << 6 | k;
    d = o >> 16 & 255;
    c = o >> 8 & 255;
    b = o & 255;
    if (l == 64) {
      g[p++] = String.fromCharCode(d)
    } else {
      if (k == 64) {
        g[p++] = String.fromCharCode(d, c)
      } else {
        g[p++] = String.fromCharCode(d, c, b)
      }
    }
  } while (h < j.length);
  f = g.join("");
  return f.replace(/ +$/, "")
}

function rc4_base64_str(f, e) {
  e = base64_decode(e);
  var c = rc4_key(f);
  var d = Array(e.length);
  for (var b = 0; b < e.length; b++) {
    d[b] = e.charCodeAt(b)
  }
  rc4_do(d, c);
  for (var b = 0; b < d.length; b++) {
    d[b] = String.fromCharCode(d[b])
  }
  return decodeURIComponent(d.join("").replace(/+/g, "%20"))
}
ec.pkg("ec.prescription");
ec.prescription.getEstimateGetOrderTime = function (e, c, d, b) {
  $.ajax({
    url: "/order/estimateTime.json?d=" + c + "&p=" + d + "&i=" + b,
    dataType: "jsonp",
    timeout: 20000,
    jsonpCallback: "jsonpEstimate",
    timeout: function () {
      e(null, true)
    },
    beforeSend: function () {
      ec.ui.loading.show({
        modal: false
      })
    },
    complete: ec.ui.loading.hide,
    success: function (f) {
      e(f.info, false)
    },
    error: function () {
      e(null, true)
    }
  })
};
getPointBalance = function () {
  $.ajax({
    url: domainUc + "/point/queryUserPointBalanceDetail.json",
    data: {},
    timeout: 10000,
    dataType: "jsonp",
    success: function (b) {
      if (b.resultCode != "200") {
        $("#newPointlogin_status").hide();
        return
      }
      var c = b.pointBlance;
      $("#userPointBalance").text(c);
      if (parseInt(c) > parseInt(999)) {
        $("#balanceicon_privilege").empty().html('<a href="/member/newpoint?t=' + new Date().getTime() + '" target="_blank">' + 999 + "+</a>")
      } else {
        $("#balanceicon_privilege").empty().html('<a href="/member/newpoint?t=' + new Date().getTime() + '" target="_blank">' + c + "</a>")
      }
      $("#balanceicon_myCenter").empty().html(c);
      $("#balanceicon_myCenter").removeClass("p-price-no")
    }
  })
};
ec.getLength = function (b) {
  if (b == null) {
    return 0
  }
  if (typeof b != "string") {
    b += ""
  }
  return b.replace(/[^ -ÿ]/g, "01").length
};
ec.isChina = function (c) {
  var b = /[一-龥]|[︰-ﾠ]/gi;
  if (!b.exec(c)) {
    return false
  } else {
    return true
  }
};
ec.cutstr = function (f, b) {
  var d = 0;
  var e = 0;
  str_cut = new String();
  e = f.length;
  if (!ec.isChina(f)) {
    b = b + 6
  }
  for (var c = 0; c < e; c++) {
    a = f.charAt(c);
    d++;
    if (escape(a).length > 4) {
      d++
    }
    str_cut = str_cut.concat(a);
    if (d >= b) {
      str_cut = str_cut.concat("...");
      return str_cut
    }
  }
  if (d < b) {
    return f
  }
};
ec.checkBrowerIE = function () {
  var b = window.navigator.userAgent;
  if (!!window.ActiveXObject || "ActiveXObject" in window || b.indexOf("MSIE") != -1 || b.indexOf("rv:") != -1) {
    return true
  } else {
    return false
  }
};
ec.freemarkerDecode = function (b) {
  b = b.replaceAll("&apos;", "'");
  b = b.replaceAll("&amp;", "&");
  b = b.replaceAll("&quot;", '"');
  b = b.replaceAll("&nbsp;", " ");
  b = b.replaceAll("&lt;", "<");
  b = b.replaceAll("&gt;", ">");
  b = b.replaceAll("	", "&nbsp;&nbsp;");
  return b
};
ec.searchHistoryUnique = function (e) {
  var c = [];
  for (var d = 0; d < e.length; d++) {
    var b = e[d];
    if ($.inArray(b, c) == -1) {
      c.push(b)
    }
  }
  return c
};
ec.pkg("ec.search");
var searchHistoryMaxLength = 48;
ec.search.querySearchHistory = function () {
  new ec.ajax().get({
    url: "/searchHistory.json?t=" + new Date().getTime(),
    type: "get",
    dateType: "json",
    timeout: 10000,
    timeoutFunction: function () {},
    successFunction: function (f) {
      if (f.success != undefined && !f.success) {
        return
      }
      var g = f.searchHistoryList;
      var e = [];
      var i;
      for (var d = 0; d < g.length; d++) {
        var c = g[d];
        var b = ec.getLength(c);
        var h = encodeURIComponent(c);
        e.push('<li><a href="/search?keyword=' + h + '" data-value="' + h + '">');
        if (b > searchHistoryMaxLength) {
          e.push($("<div/>").text(ec.cutstr(c, searchHistoryMaxLength)).html())
        } else {
          e.push($("<div/>").text(c).html())
        }
        e.push("</a></i>")
      }
      $("#search-history-list").html(e.join(""));
      $("#search-history").show()
    },
    errorFunction: function (b) {}
  })
};
ec.search.deleteSearchHistory = function () {
  new ec.ajax().get({
    url: "/search/clearUp.json?t=" + new Date().getTime(),
    type: "get",
    dateType: "json",
    timeout: 10000,
    timeoutFunction: function () {},
    successFunction: function (b) {
      if (b.success != undefined && !b.success) {
        return
      }
    },
    errorFunction: function (b) {}
  })
};
ec.account.privilege_updateProgress = function (k, g, c, b) {
  if (k >= 0 && g >= 0 && c >= 0) {
    var d = k,
      j = g,
      l = c,
      e = (l - j) / (d - j),
      f = 0;
    if (parseInt(l) >= parseInt(d)) {
      $(".canvas-left div").css({
        transform: "rotateZ(0deg)",
        background: "#F05C20"
      });
      $(".canvas-right div").css({
        transform: "rotateZ(-39deg)"
      })
    } else {
      if (e > 0.5) {
        f = 280 * e - 320;
        $(".canvas-left div").css({
          transform: "rotateZ(0deg)"
        });
        $(".canvas-right div").css({
          transform: "rotateZ(" + f + "deg)"
        });
        if (e > 0.7) {
          $(".canvas-left div").css({
            background: "#F05C20"
          })
        } else {
          f = f + 180;
          $(".canvas-left div").css({
            transform: "rotateZ(" + f + "deg)",
            background: "-webkit-gradient(linear, 0 bottom, right 0, from(#F05C20), to(#F58555))"
          });
          $(".canvas-right div").css({
            background: "-webkit-gradient(linear, 0 bottom, right 0, from(#F58555), to(#F05C20))"
          })
        }
      } else {
        if (e < 0.01 && e > 0) {
          e = 0.01
        }
        f = 265 * e - 125;
        $(".canvas-left div").css({
          transform: "rotateZ(" + f + "deg)",
          background: "-webkit-gradient(linear, 0 bottom, 0 0, from(#F05C20), to(#F58555))"
        });
        $(".canvas-right div").css({
          transform: "rotateZ(-180deg)"
        })
      }
    }
  }
  var h = $("#user-vip-level-tips");
  if (b != null) {
    switch (b) {
      case 0:
        vipColor = "#999";
        h.attr("class", "icon-vip-level-0");
        break;
      case 1:
        vipColor = "#01abdf";
        h.attr("class", "icon-vip-level-1");
        break;
      case 2:
        vipColor = "#24ca43";
        h.attr("class", "icon-vip-level-2");
        break;
      case 3:
        vipColor = "#ffb710";
        h.attr("class", "icon-vip-level-3");
        break;
      case 4:
        vipColor = "#fc5d21";
        h.attr("class", "icon-vip-level-4");
        break;
      case 5:
        vipColor = "#fc3784";
        h.attr("class", "icon-vip-level-5");
        break;
      default:
        vipColor = "#999";
        h.attr("class", "icon-vip-level-0");
        break
    }
  }
};
